package by.admonko.universaltesting.services.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import by.admonko.universaltesting.dataaccess.UserTblDao;
import by.admonko.universaltesting.datamodel.UserTbl;
import by.admonko.universaltesting.services.UserTblService;

@Service
public class UserTblServiceImpl implements UserTblService {

	@Inject
	UserTblDao userDao;

	@Override
	public UserTbl getUserById(Integer id) {

		return userDao.getById(id);
	}

	@Override
	public UserTbl getUserByPass(Integer hash) {

		return userDao.getByHash(hash);
	}

	@Override
	public List<UserTbl> getAllUser() {

		return userDao.getAll();
	}

	@Override
	public void setUser(UserTbl userTbl) {
		userTbl.setUserPasswd((userTbl.getUserName() + userTbl.getUserPasswd())
				.hashCode());
		userDao.insert(userTbl);

	}

	@Override
	public void updateUser(UserTbl userTbl) {
		userTbl.setUserPasswd((userTbl.getUserName() + userTbl.getUserPasswd())
				.hashCode());

		userDao.update(userTbl);

	}

	@Override
	public void removeUser(Integer id) {
		userDao.delete(id);

	}

	@Override
	public void removeUserList(List<Integer> ids) {
		userDao.delete(ids);

	}

	@Override
	public List<UserTbl> getUsersByGroup(Integer groupId) {
		// TODO Auto-generated method stub
		return null;
	}

}
